package com.boarsoft.boar.sequence.server;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.boarsoft.rpc.RpcConfig;

public class SequenceConfig {
	private final static Logger log = LoggerFactory.getLogger(SequenceConfig.class);
	private static Properties prop;

	static {
		init();
	}

	public static void init() {
		String path = RpcConfig.getString("rpc.conf.dir", "conf");
		InputStream is = RpcConfig.class.getClassLoader()//
				.getResourceAsStream(path.concat("/config.properties"));
		try {
			if (is == null) {
				log.warn("Can not found classpath:{}/config.properties", path);
			} else {
				prop.load(is);
			}
		} catch (IOException e) {
			log.error("Error on load sequence config.", e);
			throw new RuntimeException(e);
		}
	}

	public static String getProperty(String name) {
		return prop.getProperty(name);
	}
}